package com.toutiao.score

import scala.collection.mutable.ArrayBuffer

object TextSignature {

  
  private def isBitSet(b:BigInt, bit:Int) = {
    (b & (1L << bit)) != 0
  }

  
  def extractBitSet(z:BigInt) = {
    val vs = new Array[Byte](64)
   for (i <- 0 until 64){
     if (isBitSet(z,i)){
       vs(i) = 1
     }
   }
    
    vs
  }
  
  
  def countEquals(z1:BigInt,z2:BigInt) = {
    val ns1 = extractBitSet(z1)
    val ns2 = extractBitSet(z2)
    val ns = ns1 zip ns2
    var c = 0
    ns.foreach( n => {
      if (n._1 == n._2)
        c += 1
    })
    c
  }
  
}
